<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>个人访问</title>
    <link rel="stylesheet" type="text/css" href="/static/css/main.css">
    <link rel="stylesheet" type="text/css" href="/static/css/homepage.css">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
</head>
<body>
<div id="indextop" class="header header2 header-theme-none">
    <div class="logo fl">
        <a href="#"></a>
    </div>
    <div class="nav fl">
        <a href="/index">首页</a>
        <c:if test="${user.role.id == 3}">
            <a href="/course/stuCourseScore?stuId=${user.id}&page=1">课程成绩</a>
        </c:if>
        <c:if test="${user.role.id == 2}">
            <c:if test="${user.role.id == 2}">
                <div id="solutiontop" style="float:left;height: 60px;overflow: hidden;">
                    <a target="_blank" style="cursor: pointer;">课程管理</a>
                    <ul id="solutionul">
                        <div style="height:10px;"></div>
                        <li class="solutionli">
                            <a href="/course/courseManagement?page=1">课程管理</a>
                        </li>
                        <li class="solutionli">
                            <a href="/course/courseGrade?page=1&courseId=0">课程评分</a>
                        </li>
                        <div style="height:10px;"></div>
                    </ul>
                </div>
            </c:if>
        </c:if>
        <c:if test="${user.role.id == 2 || user.role.id == 3}">
            <a href="/problem/feedback?stuId=${user.id}&page=1">问题反馈</a>
        </c:if>
        <c:if test="${user.role.id == 1}">
            <div id="solutiontop" style="float:left;height: 60px;overflow: hidden;">
                <a target="_blank" style="cursor: pointer;">用户管理</a>
                <ul id="solutionul">
                    <div style="height:10px;"></div>
                    <li class="solutionli">
                        <a href="/user/findAllUser?page=1">用户列表</a>
                    </li>
                    <li class="solutionli">
                        <a href="/user/addUser">用户增加</a>
                    </li>
                    <div style="height:10px;"></div>
                </ul>
            </div>
        </c:if>
        <div id="solutiontop" style="float:left;height: 60px;overflow: hidden;">
            <a target="_blank" style="cursor: pointer;">统计信息</a>
            <ul id="solutionul">
                <div style="height:10px;"></div>
                <c:if test="${user.role.id == 1}">
                    <li class="solutionli">
                        <a href="/log/getUserStatistics?page=1">访问统计</a>
                    </li>
                    <li class="solutionli">
                        <a href="/log/getAllLog?page=1">用户访问</a>
                    </li>
                </c:if>
                <li class="solutionli">
                    <a href="/log/getLog?userId=${user.id}&page=1">个人访问</a>
                </li>

                <div style="height:10px;"></div>
            </ul>
        </div>
    </div>
    <style>
        #solutiontop{
            color: #357ae8;
        }
        #solutiontop:hover{
            /* 这里用auto有时无效，如果高度小于元素加起来的高度有bug */
            height: 500px !important;
            color: #357ae8;
        }
        #solutionul{
            overflow: hidden;
            clear: both;
            background: white;
            width: 120px;
            margin: -5px;
            box-shadow: 0px 0px 5px 1px rgba(80,80,80,0.4);
            position: relative;
            z-index: 1;
        }
        .solutionli a{
            width: 100%;
            text-align: center;
            box-sizing: border-box;
            color: #333 !important;
            padding: 0 10px !important;
            height: 40px !important;
            line-height: 40px !important;
        }
        .solutionli{
            height: 40px;
        }
    </style>
    <div class="log-reg fr">
        <a href="#" class="userName" style="">${user.name}</a>
        <a href="/outLogin" class="outLogin">退出登录</a>

    </div>

</div>

<div class="home-page">

    <div class="wapper">
        <div class="title">
                <span>
                    用户列表
                </span>
        </div>
        <div class="line"></div>
        <div class="content-title">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-1">
                        编号
                    </div>
                    <%--<div class="col-sm center-margin">--%>
                        <%--标题--%>
                    <%--</div>--%>
                    <div class="col-sm-2 center-margin">
                        时间
                    </div>
                    <div class="col-sm-2 ">
                        ip地址
                    </div>
                    <div class="col-sm center-margin">
                        请求uri
                    </div>
                    <div class="col-sm-1 ">
                        操作方式
                    </div>
                    <div class="col-sm center-margin">
                        参数
                    </div>
                </div>
            </div>
        </div>

        <div class="content">

            <c:if test="${logList != null}">
                <c:forEach items="${logList}" var="log" varStatus="status">
                    <c:if test="${status.count % 2 == 1}">
                        <div class="list odd">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-sm-1">
                                        <span>${log.id}</span>
                                    </div>
                                    <%--<div class="col-sm center-margin">--%>
                                        <%--<span>${log.title}</span>--%>
                                    <%--</div>--%>
                                    <div class="col-sm-2 center-margin">
                                        <span>
                                            <fmt:formatDate value="${log.createDate}" pattern="yyyy-MM-dd hh:mm:ss"></fmt:formatDate>
                                        </span>
                                    </div>
                                    <div class="col-sm-2 ">
                                        <span>${log.remoteAddr}</span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span>${log.requestUri}</span>
                                    </div>
                                    <div class="col-sm-1">
                                        <span>${log.method}</span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span>${log.params}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line"></div>
                    </c:if>
                    <c:if test="${status.count % 2 == 0}">
                        <div class="list even">
                            <div class="container-fluid">

                                <div class="row">
                                    <div class="col-sm-1">
                                        <span>${log.id}</span>
                                    </div>
                                    <div class="col-sm-2 center-margin">
                                        <span>
                                            <fmt:formatDate value="${log.createDate}" pattern="yyyy-MM-dd hh:mm:ss"></fmt:formatDate>
                                        </span>
                                    </div>
                                    <div class="col-sm-2 ">
                                        <span>${log.remoteAddr}</span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span>${log.requestUri}</span>
                                    </div>
                                    <div class="col-sm-1 ">
                                        <span>${log.method}</span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span>${log.params}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line"></div>
                    </c:if>
                </c:forEach>
                <c:if test="${logList.size() < 15}">
                    <c:forEach var="1" begin="${logList.size() + 1}" end="15" varStatus="status">
                        <c:if test="${(status.count + logList.size()) % 2 == 1}">
                            <div class="list odd">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div class="col-sm-1">
                                            <span></span>
                                        </div>
                                        <div class="col-sm-2 center-margin">
                                            <span></span>
                                        </div>
                                        <div class="col-sm-2 ">
                                            <span></span>
                                        </div>
                                        <div class="col-sm center-margin">
                                            <span></span>
                                        </div>
                                        <div class="col-sm-1 ">
                                            <span></span>
                                        </div>
                                        <div class="col-sm center-margin">
                                            <span></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line"></div>
                        </c:if>
                        <c:if test="${(status.count + logList.size()) % 2 == 0}">
                            <div class="list even">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div class="col-sm-1">
                                            <span></span>
                                        </div>
                                        <div class="col-sm-2 center-margin">
                                            <span></span>
                                        </div>
                                        <div class="col-sm-2 ">
                                            <span></span>
                                        </div>
                                        <div class="col-sm center-margin">
                                            <span></span>
                                        </div>
                                        <div class="col-sm-1 ">
                                            <span></span>
                                        </div>
                                        <div class="col-sm center-margin">
                                            <span></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="line"></div>
                        </c:if>
                    </c:forEach>
                </c:if>
            </c:if>
            <c:if test="${logList == null}">
                <c:forEach var="1" begin="1" end="15" varStatus="status">
                    <c:if test="${(status.count + logList.size()) % 2 == 1}">
                        <div class="list odd">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span></span>
                                    </div>
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span></span>
                                    </div>
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span></span>
                                    </div>
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line"></div>
                    </c:if>
                    <c:if test="${(status.count + logList.size()) % 2 == 0}">
                        <div class="list even">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span></span>
                                    </div>
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span></span>
                                    </div>
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                    <div class="col-sm center-margin">
                                        <span></span>
                                    </div>
                                    <div class="col-sm">
                                        <span></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line"></div>
                    </c:if>
                </c:forEach>
            </c:if>

        </div>

        <div style="height: 15px"></div>

        <!-- 分页 -->
        <div class=".pagination">
            <nav aria-label="Page navigation example">
                <ul class="pagination justify-content-center">
                    <c:if test="${page == 1}">
                        <li class="page-item disabled">
                            <a class="page-link" href="#" tabindex="-1">上一页</a>
                        </li>
                    </c:if>
                    <c:if test="${page != 1}">
                        <li class="page-item">
                            <a class="page-link" href="#" tabindex="-1">上一页</a>
                        </li>
                    </c:if>
                    <c:if test="${pageItemSize < 6}">
                        <c:forEach var="pageItem" begin="1" end="${pageItemSize}">
                            <c:if test="${page == pageItem}">
                                <li class="page-item active">
                                    <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                </li>
                            </c:if>
                            <c:if test="${page != pageItem}">
                                <li class="page-item">
                                    <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                </li>
                            </c:if>
                        </c:forEach>
                    </c:if>
                    <c:if test="${pageItemSize >= 6 && pageItemSize - 2 >= page}">
                        <c:if test="${page > 3}">
                            <c:forEach var="pageItem" begin="${page - 2}" end="${page + 2}">
                                <c:if test="${page == pageItem}">
                                    <li class="page-item active">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                                <c:if test="${page != pageItem}">
                                    <li class="page-item">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                            </c:forEach>
                        </c:if>
                        <c:if test="${page <= 3}">
                            <c:forEach var="pageItem" begin="1" end="5">
                                <c:if test="${page == pageItem}">
                                    <li class="page-item active">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                                <c:if test="${page != pageItem}">
                                    <li class="page-item">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                            </c:forEach>
                        </c:if>

                        <li class="page-item disabled">
                            <a class="page-link" href="#">...</a>
                        </li>
                    </c:if>
                    <c:if test="${pageItemSize >= 6 && pageItemSize - 2 < page}">
                        <c:if test="${page == pageItemSize}">
                            <c:forEach var="pageItem" begin="${pageItemSize - 4 + (pageItemSize - page)}" end="${pageItemSize}">
                                <c:if test="${page == pageItem}">
                                    <li class="page-item active">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                                <c:if test="${page != pageItem}">
                                    <li class="page-item">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                            </c:forEach>
                        </c:if>
                        <c:if test="${page != pageItemSize}">
                            <c:forEach var="pageItem" begin="${pageItemSize - 5 + (pageItemSize - page)}" end="${pageItemSize}">
                                <c:if test="${page == pageItem}">
                                    <li class="page-item active">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                                <c:if test="${page != pageItem}">
                                    <li class="page-item">
                                        <a class="page-link" href="/log/getLog?userId=${user.id}&page=${pageItem}">${pageItem}</a>
                                    </li>
                                </c:if>
                            </c:forEach>
                        </c:if>
                    </c:if>
                    <c:if test="${page == pageItemSize}">
                        <li class="page-item disabled">
                            <a class="page-link" href="#">下一页</a>
                        </li>
                    </c:if>
                    <c:if test="${page != pageItemSize}">
                        <li class="page-item">
                            <a class="page-link" href="#">下一页</a>
                        </li>
                    </c:if>
                </ul>
            </nav>
        </div>
    </div>
</div>

<!--
<div class="footer">
    <div class="cWidth">
        <div class="nav clearfix">
            <a href="https://www.ketangpai.com/index/abouts.html">脚标</a>
        </div>
        <p>这里写个人信息</p>
    </div>
</div>
-->

<script type="text/javascript" src="/static/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/static/js/main.js"></script>


</body>
</html>